#include "../Include/LogSystem.h"

IMPLEMENT_UNMANED_SINGLETON_X(CLogSystem)


CLogSystem::CLogSystem()
	:m_nLogLevel(E_LOG_LEVEL::LOG_LEVEL_DUMP | E_LOG_LEVEL::LOG_LEVEL_INFO | E_LOG_LEVEL::LOG_LEVEL_ERROR),
	m_bSaveToFile(false),
	m_strFileName(""),
	m_strLocalIp("127.0.0.1"),
	m_nLocalPort(6666)
{
	m_nDivideSize = 1024 * 1024 * 10;
	m_bHasFileInfo = false;
	m_bHasPid = false;
}

CLogSystem::~CLogSystem()
{

}

void CLogSystem::SetLogLevel(int nLogLevel)
{
	m_nLogLevel = nLogLevel;
}

void CLogSystem::SetFileInfo(bool bSaveToFile, const std::string& strfileName)
{
	m_bSaveToFile = bSaveToFile;
	m_strFileName = strfileName;
	if (m_bSaveToFile)
	{
		CLogWriter::Instance().StartWriteFileThread();
	}
}

void CLogSystem::SetLoaclPort(int nLocalPort, const std::string& strLocalIp)
{
	m_strLocalIp = strLocalIp;
	m_nLocalPort = nLocalPort;
}

void CLogSystem::SetDivideSize(int nDivideSize)
{
	m_nDivideSize = nDivideSize;
}

void CLogSystem::SetLogHeader(bool bHasFileInfo, bool bHasPid)
{
	m_bHasFileInfo = bHasFileInfo;
	m_bHasPid = bHasPid;
}

bool CLogSystem::IsSaveToFile() const
{
	return m_bSaveToFile;
}

bool CLogSystem::IsHasFileInfo() const
{
	return m_bHasFileInfo;
}

bool CLogSystem::IsHasPid() const
{
	return m_bHasPid;
}

const std::string& CLogSystem::GetFileName() const
{
	return m_strFileName;
}

const std::string& CLogSystem::GetLocalIp() const
{
	return m_strLocalIp;
}

int CLogSystem::GetLocalPort() const
{
	return m_nLocalPort;
}

int CLogSystem::GetDivideSize() const
{
	return m_nDivideSize;
}

int CLogSystem::GetLogLevel() const
{
	return m_nLogLevel;
}

